package by.yakusekmaxim.bookgid.webapp.page;

import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import by.yakusekmaxim.bookgid.webapp.page.admin.ConsolePage;
import by.yakusekmaxim.bookgid.webapp.page.home.author.AuthorPage;
import by.yakusekmaxim.bookgid.webapp.page.home.book.BookPage;
import by.yakusekmaxim.bookgid.webapp.page.home.myLibrary.MyLibraryPage;
import by.yakusekmaxim.bookgid.webapp.page.login.LanguageSelectionPanel;
import by.yakusekmaxim.bookgid.webapp.page.login.LoginLogoutPanel;

public abstract class HomeLayout extends WebPage {
	
	@Override
	protected void onInitialize() {
		super.onInitialize();
		
		add(new LanguageSelectionPanel("lang"));
		
		add(new LoginLogoutPanel("logPanel"));
		add(new Label("headerTitle", getPageTitle()));
	
		add(new Link<Object>("pageLinkWithArgs") {
			@Override
			public void onClick() {
				ConsolePage adminPage = new ConsolePage();
				setResponsePage(adminPage);
			}
		});
		
		add(new Link<Object>("linkBookPage"){

			@Override
			public void onClick() {
				BookPage bookPage = new BookPage();
				setResponsePage(bookPage);
			}
			
		});
		
		add(new Link<Object>("linkAuthorPage"){

			@Override
			public void onClick() {
				AuthorPage authorPage = new AuthorPage();
				setResponsePage(authorPage);
			}
			
		});
		
		add(new Link<Object>("linkMyLibraryPage"){

			@Override
			public void onClick() {
				MyLibraryPage myLibraryPage = new MyLibraryPage();
				setResponsePage(myLibraryPage);
			}
			
		});
		
		addPanel();
	}

	protected IModel<String> getPageTitle() {
		return new Model<String>(getClass().getSimpleName());
	}

	protected abstract MarkupContainer addPanel();
    
}
